home *** CD-ROM | disk | FTP | other *** search
/ PC Basics 53 / PC Basics Issue 53.iso / Software / Internet / Invboard.exe / PC Basics 53 / Invboard / upload / sources / Admin / ad_modlogs.php < prev    next >
Encoding:
PHP Script  |  2002-06-12  |  8.2 KB  |  282 lines

  1. <?php
  2.  
  3. /*
  4. +--------------------------------------------------------------------------
  5. |   IBFORUMS v1
  6. |   ========================================
  7. |   by Matthew Mecham and David Baxter
  8. |   (c) 2001,2002 IBForums
  9. |   http://www.ibforums.com
  10. |   ========================================
  11. |   Web: http://www.ibforums.com
  12. |   Email: phpboards@ibforums.com
  13. |   Licence Info: phpib-licence@ibforums.com
  14. +---------------------------------------------------------------------------
  15. |
  16. |   > Import functions
  17. |   > Module written by Matt Mecham
  18. |   > Date started: 22nd April 2002
  19. |
  20. |    > Module Version Number: 1.0.0
  21. +--------------------------------------------------------------------------
  22. */
  23.  
  24.  
  25. // Ensure we've not accessed this script directly:
  26.  
  27.  
  28.  
  29. $idx = new ad_modlogs();
  30.  
  31.  
  32. class ad_modlogs {
  33.  
  34.     var $base_url;
  35.  
  36.     function ad_modlogs() {
  37.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  38.  
  39.         switch($IN['code'])
  40.         {
  41.         
  42.             case 'view':
  43.                 $this->view();
  44.                 break;
  45.                 
  46.             case 'remove':
  47.                 $this->remove();
  48.                 break;
  49.                 
  50.                 
  51.             //-------------------------
  52.             default:
  53.                 $this->list_current();
  54.                 break;
  55.         }
  56.         
  57.     }
  58.     
  59.     //---------------------------------------------
  60.     // Remove archived files
  61.     //---------------------------------------------
  62.     
  63.     function view()
  64.     {
  65.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  66.         
  67.         $start = $IN['st'] ? $IN['st'] : 0;
  68.         
  69.         $ADMIN->page_detail = "Viewing all actions by a moderator";
  70.         $ADMIN->page_title  = "Moderator Logs Manager";
  71.     
  72.         if ($IN['search_string'] == "")
  73.         {
  74.             $DB->query("SELECT COUNT(id) as count FROM ibf_moderator_logs WHERE member_id='".$IN['mid']."'");
  75.             $row = $DB->fetch_row();
  76.             
  77.             $row_count = $row['count'];
  78.             
  79.             $query = "&act=modlog&mid={$IN['mid']}&code=view";
  80.             
  81.             $DB->query("SELECT m.*, f.id as forum_id, f.name FROM ibf_moderator_logs m, ibf_forums f WHERE m.member_id='".$IN['mid']."' AND f.id=m.forum_id ORDER BY m.ctime DESC LIMIT $start, 20");
  82.             
  83.         }
  84.         else
  85.         {
  86.             $IN['search_string'] = urldecode($IN['search_string']);
  87.             
  88.             if ( ($IN['search_type'] == 'topic_id') or ($IN['search_type'] == 'forum_id') )
  89.             {
  90.                 $dbq = "m.".$IN['search_type']."='".$IN['search_string']."'";
  91.             }
  92.             else
  93.             {
  94.                 $dbq = "m.".$IN['search_type']." LIKE '%".$IN['search_string']."%'";
  95.             }
  96.         
  97.             $DB->query("SELECT COUNT(m.id) as count FROM ibf_moderator_logs m WHERE $dbq");
  98.             $row = $DB->fetch_row();
  99.             
  100.             $row_count = $row['count'];
  101.             
  102.             $query = "&act=modlog&code=view&search_type={$IN['search_type']}&search_string=".urlencode($IN['search_string']);
  103.             
  104.             $DB->query("SELECT m.*, f.id as forum_id, f.name FROM ibf_moderator_logs m, ibf_forums f WHERE $dbq AND f.id=m.forum_id ORDER BY m.ctime DESC LIMIT $start, 20");
  105.             
  106.         
  107.         
  108.         }
  109.         
  110.         $links = $std->build_pagelinks( array( 'TOTAL_POSS'  => $row_count,
  111.                                                'PER_PAGE'    => 20,
  112.                                                'CUR_ST_VAL'  => $start,
  113.                                                'L_SINGLE'    => "Single Page",
  114.                                                'L_MULTI'     => "Pages: ",
  115.                                                'BASE_URL'    => $ADMIN->base_url.$query,
  116.                                              )
  117.                                       );
  118.                                       
  119.         $ADMIN->page_detail = "You may view and remove actions performed by your moderators";
  120.         $ADMIN->page_title  = "Moderator Logs Manager";
  121.         
  122.         //+-------------------------------
  123.         
  124.         $SKIN->td_header[] = array( "Member Name"            , "15%" );
  125.         $SKIN->td_header[] = array( "Action Perfomed"        , "15%" );
  126.         $SKIN->td_header[] = array( "Forum"                  , "15%" );
  127.         $SKIN->td_header[] = array( "Topic Title"            , "25%" );
  128.         $SKIN->td_header[] = array( "Time of action"         , "20%" );
  129.         $SKIN->td_header[] = array( "IP address"             , "10%" );
  130.         
  131.         $ADMIN->html .= $SKIN->start_table( "Saved Moderator Logs" );
  132.         $ADMIN->html .= $SKIN->add_td_basic($links, 'center', 'catrow');
  133.         
  134.         if ( $DB->get_num_rows() )
  135.         {
  136.             while ( $row = $DB->fetch_row() )
  137.             {
  138.             
  139.                 $row['ctime'] = $std->get_date( $row['ctime'], 'LONG' );
  140.                 
  141.                 $sess_id             = preg_replace( "/^.+?s=(\w{32}).+?$/" , "\\1", $row['http_referer'] );
  142.                 $row['http_referer'] = preg_replace( "/s=(\w){32}/" , ""  , $row['http_referer'] );
  143.                 
  144.                 $ADMIN->html .= $SKIN->add_td_row( array( "<b>{$row['member_name']}</b>",
  145.                                                           "<span style='font-weight:bold;color:red'><a href='#' onClick=\"alert('HTTP REFERRER OF ACTION:\\n{$row['http_referer']}\\nSESSION ID OF ACTION:\\n$sess_id')\">{$row['action']}</a></span>",
  146.                                                           "<b>{$row['name']}</b>",
  147.                                                           "{$row['topic_title']}",
  148.                                                           "{$row['ctime']}",
  149.                                                           "{$row['ip_address']}",
  150.                                                  )      );
  151.             
  152.             
  153.             }
  154.         }
  155.         else
  156.         {
  157.             $ADMIN->html .= $SKIN->add_td_basic("<center>No results</center>");
  158.         }
  159.         
  160.         $ADMIN->html .= $SKIN->add_td_basic($links, 'center', 'tdtop');
  161.         
  162.         $ADMIN->html .= $SKIN->end_table();
  163.         
  164.         
  165.         //+-------------------------------
  166.         //+-------------------------------
  167.         
  168.         $ADMIN->output();
  169.         
  170.     }
  171.     
  172.     //---------------------------------------------
  173.     // Remove archived files
  174.     //---------------------------------------------
  175.     
  176.     function remove()
  177.     {
  178.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  179.     
  180.         if ($IN['mid'] == "")
  181.         {
  182.             $ADMIN->error("You did not select a member ID to remove by!");
  183.         }
  184.         
  185.         $DB->query("DELETE FROM ibf_moderator_logs WHERE member_id='".$IN['mid']."'");
  186.         
  187.         $std->boink_it($ADMIN->base_url."&act=modlog");
  188.         exit();
  189.     
  190.     
  191.     }
  192.     
  193.     
  194.  
  195.     
  196.     
  197.     //-------------------------------------------------------------
  198.     // SHOW ALL LANGUAGE PACKS
  199.     //-------------------------------------------------------------
  200.     
  201.     function list_current()
  202.     {
  203.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  204.         
  205.         $form_array = array();
  206.     
  207.         $ADMIN->page_detail = "You may view and remove actions performed by your moderators";
  208.         $ADMIN->page_title  = "Moderator Logs Manager";
  209.         
  210.         //+-------------------------------
  211.         
  212.         $SKIN->td_header[] = array( "Member Name"            , "30%" );
  213.         $SKIN->td_header[] = array( "Actions Perfomed"       , "20%" );
  214.         $SKIN->td_header[] = array( "View all by member"     , "20%" );
  215.         $SKIN->td_header[] = array( "Remove all by member"   , "30%" );
  216.         
  217.         $ADMIN->html .= $SKIN->start_table( "Saved Moderator Logs" );
  218.         
  219.         $DB->query("SELECT m.*, count(m.id) as act_count from ibf_moderator_logs m GROUP BY m.member_id ORDER BY act_count DESC");
  220.         
  221.         while ( $r = $DB->fetch_row() )
  222.         {
  223.             
  224.             $ADMIN->html .= $SKIN->add_td_row( array( "<b>{$r['member_name']}</b>",
  225.                                                       "<center>{$r['act_count']}</center>",
  226.                                                       "<center><a href='".$SKIN->base_url."&act=modlog&code=view&mid={$r['member_id']}'>View</a></center>",
  227.                                                       "<center><a href='".$SKIN->base_url."&act=modlog&code=remove&mid={$r['member_id']}'>Remove</a></center>",
  228.                                              )      );
  229.         }
  230.             
  231.         
  232.         
  233.         $ADMIN->html .= $SKIN->end_table();
  234.         
  235.         
  236.         //+-------------------------------
  237.         //+-------------------------------
  238.         
  239.         $ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , 'view'     ),
  240.                                                   2 => array( 'act'   , 'modlog'       ),
  241.                                          )      );
  242.         
  243.         $SKIN->td_header[] = array( " "  , "40%" );
  244.         $SKIN->td_header[] = array( " "  , "60%" );
  245.         
  246.         $ADMIN->html .= $SKIN->start_table( "Search Moderator Logs" );
  247.         
  248.         $form_array = array(
  249.                               0 => array( 'topic_title', 'Topic Title' ),
  250.                               1 => array( 'ip_address',  'IP Address'  ),
  251.                               2 => array( 'member_name', 'Member Name' ),
  252.                               3 => array( 'topic_id'   , 'Topic ID'    ),
  253.                               4 => array( 'forum_id'   , 'Forum ID'    )
  254.                            );
  255.             
  256.         //+-------------------------------
  257.         
  258.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Search for...</b>" ,
  259.                                                     $SKIN->form_input( "search_string")
  260.                                  )      );
  261.                                  
  262.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Search in...</b>" ,
  263.                                                     $SKIN->form_dropdown( "search_type", $form_array)
  264.                                  )      );
  265.         
  266.         $ADMIN->html .= $SKIN->end_form("Search");
  267.                                          
  268.         $ADMIN->html .= $SKIN->end_table();
  269.         
  270.         //+-------------------------------
  271.         //+-------------------------------
  272.         
  273.         $ADMIN->output();
  274.     
  275.     }
  276.     
  277.     
  278.     
  279. }
  280.  
  281.  
  282. ?>